<template>
<div class="add-project-wrapper">
    <modal
        :title="modalTitle"
        v-model="modalShow"
        :auto-close="false"
        :mask-closable="false">
        <Form ref="form" :model="panel" :grid="1" :label-width="90" label-position="right">
            <Form-item label="面板名称">
                <Input placeholder="面板名称" clearable class="normal-input" v-model="panelLayoutName"></Input>
            </Form-item>
            <!-- <Form-item label="面板状态">
                <Select v-model="panel.status">
                    <Option v-for="item in statusList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                </Select>
            </Form-item> -->
            <!-- <Form-item label="面板标签">
                <Input placeholder="面板标签(多个标签请用;区分)" clearable type="textarea" class="normal-input-area" :rows="2" v-model="panelLayoutTag"></Input>
            </Form-item> -->
        </Form>
        <div slot="footer">
            <Button type="primary" @click="save">保存</Button>
            <Button type="warning" @click="cancel">取消</Button>
        </div>
    </modal>
</div>
</template>

<script>
import util         from 'util'
import getData      from 'getData'
export default {
    data () {
        return {
            panel: {},
            modalShow: false,
            modalTitle: '基本信息编辑',
            panelLayoutTag:"",
            panelLayoutName:"",
            edit:{
                panelLayoutTag:"",
                panelLayoutName:"",
            },
            statusList:[
                {value:1,label:"启用"},
                {value:0,label:"禁用"},
            ],
        }
    },
    methods: {
        cancel() {
            this.modalShow = false;
        },
        save() {
            var _this = this;
            this.panel.layoutTag = this.panelLayoutTag;
            this.panel.layoutName = this.panelLayoutName;
            console.log(this.panel)
            getData.post("saveLayout",this.panel).then(function(res){
                if(res.status ==200 && res.data.code =='000'){
                    _this.modalShow = false;
                    _this.$Message.success('保存成功！');
                }else{
                    _this.$Message.error("查询面板信息失败!");
                    _this.panel.layoutTag = _this.edit.panelLayoutTag;
                    _this.panel.layoutName = _this.edit.panelLayoutName;
                }
            });
        },
        show(panel) {
            this.panel = panel;
            this.panelLayoutTag = this.panel.layoutTag;
            this.panelLayoutName = this.panel.layoutName;
            this.edit.panelLayoutTag = this.panel.layoutTag;
            this.edit.panelLayoutName = this.panel.layoutName;
            this.modalShow = true;
        }
    }
}
</script>
